package com.zr.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.zr.service.DeletePointService;
import com.zr.service.DeletePsfwService;
import com.zr.service.DeletePsjgService;

@Controller
@Scope(value="prototype")
public class DeletePoints implements ServletResponseAware,ServletRequestAware{
	private int[] pids;
	private HttpServletResponse resp;
	private HttpServletRequest req;
	
	public int[] getPids() {
		return pids;
	}
	public void setPids(int[] pids) {
		this.pids = pids;
	}
	@Resource
	private DeletePsfwService deletepsfw;
	@Resource
	private DeletePsjgService deletepsjg;
	@Resource
	private DeletePointService deletepoints;
	
	public void deletepoints(){
		try {
			req.setCharacterEncoding("utf8");
			resp.setCharacterEncoding("utf8");
		} catch (UnsupportedEncodingException e1) {
			e1.printStackTrace();
		}
		deletepsfw.deletepsfw(pids);
		deletepsjg.deletepsjg(pids);
		deletepoints.deletepoints(pids);
		PrintWriter pw;
		try {
			pw = resp.getWriter();
			pw.write("1");
			pw.flush();
			pw.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	@Override
	public void setServletResponse(HttpServletResponse resp) {
		this.resp=resp;
	}
	@Override
	public void setServletRequest(HttpServletRequest req) {
		this.req = req;
	}
	
	
}
